import AppConst from "../AppConst";
import LayerMgr from "../view/LayerMgr";


export default class Wait {
    private static _inst: Wait = null;
    public static get inst(): Wait { return this._inst || (this._inst = new Wait()); }

    private _nodeWait: cc.Node = null;


    private constructor() {
        cc.loader.loadRes('mi/core/Wait', (err: Error, prefab: cc.Prefab) => {
            if (!err) {
                this._nodeWait = cc.instantiate(prefab);
                this._nodeWait.active = false;
                LayerMgr.setLayer(this._nodeWait, AppConst.viewLayer.Top);
            } else {
                cc.error('[mi]找不到Res[mi/core/Wait], err:', err);
            }
        });
    }


    public show(show: boolean): void {
        if (this._nodeWait) this._nodeWait.active = show;
    }
}
